<%@ page language="java" contentType="text/html; charset=utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>鼎嘉旅游-用户注册</title>
	<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/statics/css/main.css">
	<script type="text/javascript" src="${pageContext.request.contextPath }/statics/js/jquery-1.8.3.js"></script>
	
</head>
<%@ include file="/WEB-INF/elements/header.jsp" %>
<body style="background-image: url(${base }/statics/images/login_bg.jpg);" >
<!-- content begin -->

	<div id="content">
		 <div class="lg-ad" title="登录注册背景" style="height: 600px;">
			<!-- <img src="" alt="登录注册背景"> -->
			<a href="#"></a>
		</div> 
		<div id="login-box">
			<div class="way lg-account">
				<div class="lg-tip">
					<h4>密码登录</h4>
					<i class="iconfont way-icon">&#xe64a;</i>
				</div>
				<form id="account-form" action="${base }/user/register.html" class="layui-form" method="post">
					<div>
						<label for="username"><i class="iconfont">&#xe649;</i></label>
						<input type="text" lay-verify="required|phone" name="phone" id="username" placeholder="手机号/邮箱">
						<i id="clear-icon" class="iconfont">&#xe65b;</i>
					</div>
					
					<div>
						<label for="username"><i class="iconfont">&#xe649;</i></label>
						<input type="text" style="width:80px; " lay-verify="random" name="random" id="random" placeholder="验证码">
						 <img style="margin-left:10px; height:35px; width:70px;" id="rimg"  src="${base}/login/image.jpg">
     					 <a href="javascript:void(0);" onclick="change();">换一张</a> </td></tr>
     					<div id="msg" style="color:red; height:0px;" ></div>
					</div>
					<div>
						<label for="password"><i class="iconfont">&#xe64c;</i></label>
						<input type="text" lay-verify="email" name="email" id="password" placeholder="请输入邮箱">
					</div>
					<div>
						<label for="password"><i class="iconfont">&#xe64c;</i></label>
						<input type="password" lay-verify="pass" name="pwd" id="password" placeholder="请输入密码">
						<div id="pwd2" style="color:red; height:0px;" ></div>
					</div>
					<div>
						<label for="password"><i class="iconfont">&#xe64c;</i></label>
						<input type="password" lay-verify="pass" name="pwd2" id="password2" placeholder="确认密码">
						
					</div>
					<input type="submit" lay-submit="" id="lg-btn" name="submit" value="登 录">
					<input type="hidden" name="submitted" value="true">
				</form>
				<!-- <p class="lg-links">
					<a href="forgot_pass.html">忘记密码</a>
					<a href="register.html">免费注册</a>
				</p> -->
				<p id="lg-error">
					<i class="iconfont error-icon">&#xe65b;</i>
					<span></span>
				</p>
			</div>
		</div>
	</div>


<!-- content end -->
<%@ include file="/WEB-INF/elements/footer.jsp" %>
<script src="layui/layui.js" charset="utf-8"></script>
<script type="text/javascript" src="${base }/js/SHA1.js"></script>
	<script type="text/javascript" src="js/form.js"></script>
<script type="text/javascript" src="js/jquery-1.9.1.min.js"></script>
<script>
function change(){
	document.getElementById("rimg").src="image.jsp?id="+Math.random();
}
 	/* 验证码正确性 */
	$(function(){
		
		$("#random").blur(function(){
			var random=$("#random").val();
			//alert(random);
			$.ajax({
				url:base+"/login/login.do",
				type:"post",
				data:"random="+random,
				dataType:"json",
				success:function(result){
					if(random.toLowerCase()==result.code.toLowerCase()){
						$("#msg").html("验证码正确！");
					}else{
						$("#msg").html("验证码不正确！");
					}
					
				}
			})
		});
		
		$("#password2").blur(function(){
			var pwd=$("#password").val();
			var pwd2=$("#password2").val();
			if(pwd!=pwd2){
				flag=false;
				$("#pwd2").html("两次密码不一样！");
			}
		})
	}); 
	
layui.use(['form', 'layedit', 'laydate'], function(){
  var form = layui.form
  ,layer = layui.layer
  
  var flag=true; //表单是否提交
//自定义验证规则
  form.verify({
	  title: function(value){
	      if(value.length < 5){
	    	  flag=false;
	        return '标题至少得5个字符啊';
	      }
	    }
  	,random:function(value){
  		$.ajax({
			url:"login_vificationCode.action",
			type:"post",
			data:"random="+random,
			dataType:"json",
			success:function(result){
				if(value.toLowerCase()==result.code.toLowerCase()){
					return "验证码正确！"
				}else{
					flag=false;
					return "验证码不正确！"
				}
			}
		})
  	}
    ,pass: [/(.+){6,12}$/, '密码在6到12位之间']
    ,content: function(value){
      layedit.sync(editIndex);
    }
  });
  
//监听提交
  form.on('submit(demo1)', function(data){
  return flag;
  });
  
});
</script>


</body>
</html>